package com.chrray.position.domain.dto.search;

import com.chrray.position.enums.app.FdGenderEnum;
import com.chrray.position.enums.app.FdJobType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * @author liujianxin
 * @date 2024/08/29 22:55
 */
@Data
public class JobPageSearch extends BaseParam {

    @ApiModelProperty(value = "发布人id, 从职位详情-雇主发布的职位那里跳转使用")
    private Long userId;

    @ApiModelProperty(value = "经度")
    @NotNull(message = "经度不能为空")
    private double lon;
    @ApiModelProperty(value = "纬度")
    @NotNull(message = "纬度不能为空")
    private double lat;

    @ApiModelProperty(value = "职位类型:1-短期,2-长期,3-新农人")
    private Integer jobType;

    @ApiModelProperty(value = "职位分类ID")
    private Long jobCategoryId;

    @ApiModelProperty(value = "区域ID")
    private String districtId;

    @ApiModelProperty(value = "范围,单位km")
    private Integer distance = 100;

    @ApiModelProperty(value = "排序: 0-默认, 1-距离最近, 2-最新发布, 3-报酬最高")
    private int orderBy;


    @ApiModelProperty(value = "性别：1-男,2-女,3-不限")
    private Integer gender;

    @ApiModelProperty(value = "年龄开始,岁")
    private Integer ageStart;

    @ApiModelProperty(value = "年龄结束,岁")
    private Integer ageEnd;

    @ApiModelProperty(value = "报酬单价：元-最低")
    private BigDecimal salaryPriceStart;
    @ApiModelProperty(value = "报酬单价：元-最高")
    private BigDecimal salaryPriceEnd;

    @ApiModelProperty(value = "职位名称")
    private String jobName;
    public String getOrderByStr() {
        if(orderBy == 0) {
            return "jobs.id desc";
        }
        if(orderBy == 1) {
            return "distance asc";
        }
        if(orderBy == 2) {
            return "jobs.publish_time desc";
        }
        if(orderBy == 3) {
            return "max_jobs.max_salary_price desc, jobs.salary_price desc";
        }
        return null;
    }
}
